import java.awt.*;
import java.awt.event.*;
 
public class CanvasDemo extends Canvas {
    public static void main(String[] args) {
        Frame frame = new Frame("AWTDemo");
        frame.addWindowListener(new AdapterDemo());
        frame.setSize(200, 220);
         
        CanvasDemo canvas = new CanvasDemo();
        frame.add(canvas, BorderLayout.CENTER);
         
        frame.setVisible(true);
    }
     
    public void paint(Graphics g) {
        g.drawRect(10, 10, 180, 180);
    }
}
 
class AdapterDemo extends WindowAdapter {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
}